package render.tree
{
	import mx.collections.ICollectionView;
	import mx.controls.treeClasses.ITreeDataDescriptor;

	public class StructureDescriptor implements ITreeDataDescriptor
	{
		public static const NODE_TYPE_CATEGORY:String = "cat";
		public static const NODE_TYPE_INSTANCE:String = "ins";
		public static const NODE_TYPE_PAGECONTORL:String="pag";
		public static const NODE_TYPE_ATTRIBUTE:String = "att";
		
		private var tree:TreeStructureRender;

		public function StructureDescriptor(tree:TreeStructureRender)
		{
			this.tree = tree;			
		}

		public function getChildren(node:Object, model:Object=null):ICollectionView
		{
			trace(" get child once");
			return INode(node).getChildren();
		}
		
		public function hasChildren(node:Object, model:Object=null):Boolean
		{
			return INode(node).getChildrenAmount() != 0;
		}
		
		public function isBranch(node:Object, model:Object=null):Boolean
		{
			if(tree.expandOnInstance)
				return (INode(node).getNodeType() == NODE_TYPE_CATEGORY) 	
					|| (INode(node).getNodeType() == NODE_TYPE_INSTANCE);
			return INode(node).getNodeType() == NODE_TYPE_CATEGORY;
		}
		
		public function getData(node:Object, model:Object=null):Object
		{
			return node;
		}
		
		
		//-----------------------------------------
		//
		//   Support for edting
		//
		//-----------------------------------------
		
		public function addChildAt(parent:Object, newChild:Object, index:int, model:Object=null):Boolean
		{
			return false;
		}
		
		public function removeChildAt(parent:Object, child:Object, index:int, model:Object=null):Boolean
		{
			return false;
		}
		
	}
}